home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / gcc / gcc261a.zoo / info / gcc.info-2 < prev    next >
Encoding:
GNU Info File  |  1994-10-31  |  47.2 KB  |  1,182 lines

  1. This is Info file gcc.info, produced by Makeinfo-1.54 from the input
  2. file gcc.texi.
  3.  
  4.    This file documents the use and the internals of the GNU compiler.
  5.  
  6.    Published by the Free Software Foundation 675 Massachusetts Avenue
  7. Cambridge, MA 02139 USA
  8.  
  9.    Copyright (C) 1988, 1989, 1992, 1993 Free Software Foundation, Inc.
  10.  
  11.    Permission is granted to make and distribute verbatim copies of this
  12. manual provided the copyright notice and this permission notice are
  13. preserved on all copies.
  14.  
  15.    Permission is granted to copy and distribute modified versions of
  16. this manual under the conditions for verbatim copying, provided also
  17. that the sections entitled "GNU General Public License" and "Protect
  18. Your Freedom--Fight `Look And Feel'" are included exactly as in the
  19. original, and provided that the entire resulting derived work is
  20. distributed under the terms of a permission notice identical to this
  21. one.
  22.  
  23.    Permission is granted to copy and distribute translations of this
  24. manual into another language, under the above conditions for modified
  25. versions, except that the sections entitled "GNU General Public
  26. License" and "Protect Your Freedom--Fight `Look And Feel'", and this
  27. permission notice, may be included in translations approved by the Free
  28. Software Foundation instead of in the original English.
  29.  
  30. File: gcc.info,  Node: Overall Options,  Next: Invoking G++,  Prev: Option Summary,  Up: Invoking GCC
  31.  
  32. Options Controlling the Kind of Output
  33. ======================================
  34.  
  35.    Compilation can involve up to four stages: preprocessing, compilation
  36. proper, assembly and linking, always in that order.  The first three
  37. stages apply to an individual source file, and end by producing an
  38. object file; linking combines all the object files (those newly
  39. compiled, and those specified as input) into an executable file.
  40.  
  41.    For any given input file, the file name suffix determines what kind
  42. of compilation is done:
  43.  
  44. `FILE.c'
  45.      C source code which must be preprocessed.
  46.  
  47. `FILE.i'
  48.      C source code which should not be preprocessed.
  49.  
  50. `FILE.ii'
  51.      C++ source code which should not be preprocessed.
  52.  
  53. `FILE.m'
  54.      Objective-C source code.  Note that you must link with the library
  55.      `libobjc.a' to make an Objective-C program work.
  56.  
  57. `FILE.h'
  58.      C header file (not to be compiled or linked).
  59.  
  60. `FILE.cc'
  61. `FILE.cxx'
  62. `FILE.cpp'
  63. `FILE.C'
  64.      C++ source code which must be preprocessed.  Note that in `.cxx',
  65.      the last two letters must both be literally `x'.  Likewise, `.C'
  66.      refers to a literal capital C.
  67.  
  68. `FILE.s'
  69.      Assembler code.
  70.  
  71. `FILE.S'
  72.      Assembler code which must be preprocessed.
  73.  
  74. `OTHER'
  75.      An object file to be fed straight into linking.  Any file name
  76.      with no recognized suffix is treated this way.
  77.  
  78.    You can specify the input language explicitly with the `-x' option:
  79.  
  80. `-x LANGUAGE'
  81.      Specify explicitly the LANGUAGE for the following input files
  82.      (rather than letting the compiler choose a default based on the
  83.      file name suffix).  This option applies to all following input
  84.      files until the next `-x' option.  Possible values for LANGUAGE
  85.      are:
  86.           c  objective-c  c++
  87.           c-header  cpp-output  c++-cpp-output
  88.           assembler  assembler-with-cpp
  89.  
  90. `-x none'
  91.      Turn off any specification of a language, so that subsequent files
  92.      are handled according to their file name suffixes (as they are if
  93.      `-x' has not been used at all).
  94.  
  95.    If you only want some of the stages of compilation, you can use `-x'
  96. (or filename suffixes) to tell `gcc' where to start, and one of the
  97. options `-c', `-S', or `-E' to say where `gcc' is to stop.  Note that
  98. some combinations (for example, `-x cpp-output -E' instruct `gcc' to do
  99. nothing at all.
  100.  
  101. `-c'
  102.      Compile or assemble the source files, but do not link.  The linking
  103.      stage simply is not done.  The ultimate output is in the form of an
  104.      object file for each source file.
  105.  
  106.      By default, the object file name for a source file is made by
  107.      replacing the suffix `.c', `.i', `.s', etc., with `.o'.
  108.  
  109.      Unrecognized input files, not requiring compilation or assembly,
  110.      are ignored.
  111.  
  112. `-S'
  113.      Stop after the stage of compilation proper; do not assemble.  The
  114.      output is in the form of an assembler code file for each
  115.      non-assembler input file specified.
  116.  
  117.      By default, the assembler file name for a source file is made by
  118.      replacing the suffix `.c', `.i', etc., with `.s'.
  119.  
  120.      Input files that don't require compilation are ignored.
  121.  
  122. `-E'
  123.      Stop after the preprocessing stage; do not run the compiler
  124.      proper.  The output is in the form of preprocessed source code,
  125.      which is sent to the standard output.
  126.  
  127.      Input files which don't require preprocessing are ignored.
  128.  
  129. `-o FILE'
  130.      Place output in file FILE.  This applies regardless to whatever
  131.      sort of output is being produced, whether it be an executable file,
  132.      an object file, an assembler file or preprocessed C code.
  133.  
  134.      Since only one output file can be specified, it does not make
  135.      sense to use `-o' when compiling more than one input file, unless
  136.      you are producing an executable file as output.
  137.  
  138.      If `-o' is not specified, the default is to put an executable file
  139.      in `a.out', the object file for `SOURCE.SUFFIX' in `SOURCE.o', its
  140.      assembler file in `SOURCE.s', and all preprocessed C source on
  141.      standard output.
  142.  
  143. `-v'
  144.      Print (on standard error output) the commands executed to run the
  145.      stages of compilation.  Also print the version number of the
  146.      compiler driver program and of the preprocessor and the compiler
  147.      proper.
  148.  
  149. `-pipe'
  150.      Use pipes rather than temporary files for communication between the
  151.      various stages of compilation.  This fails to work on some systems
  152.      where the assembler is unable to read from a pipe; but the GNU
  153.      assembler has no trouble.
  154.  
  155. File: gcc.info,  Node: Invoking G++,  Next: C Dialect Options,  Prev: Overall Options,  Up: Invoking GCC
  156.  
  157. Compiling C++ Programs
  158. ======================
  159.  
  160.    C++ source files conventionally use one of the suffixes `.C', `.cc',
  161. or `.cxx'; preprocessed C++ files use the suffix `.ii'.  GNU CC
  162. recognizes files with these names and compiles them as C++ programs
  163. even if you call the compiler the same way as for compiling C programs
  164. (usually with the name `gcc').
  165.  
  166.    However, C++ programs often require class libraries as well as a
  167. compiler that understands the C++ language--and under some
  168. circumstances, you might want to compile programs from standard input,
  169. or otherwise without a suffix that flags them as C++ programs.  `g++'
  170. is a program that calls GNU CC with the default language set to C++,
  171. and automatically specifies linking against the GNU class library
  172. libg++.  (1) On many systems, the script `g++' is also installed with
  173. the name `c++'.
  174.  
  175.    When you compile C++ programs, you may specify many of the same
  176. command-line options that you use for compiling programs in any
  177. language; or command-line options meaningful for C and related
  178. languages; or options that are meaningful only for C++ programs.  *Note
  179. Options Controlling C Dialect: C Dialect Options, for explanations of
  180. options for languages related to C.  *Note Options Controlling C++
  181. Dialect: C++ Dialect Options, for explanations of options that are
  182. meaningful only for C++ programs.
  183.  
  184.    ---------- Footnotes ----------
  185.  
  186.    (1)  Prior to release 2 of the compiler, there was a separate `g++'
  187. compiler.  That version was based on GNU CC, but not integrated with
  188. it.  Versions of `g++' with a `1.XX' version number--for example, `g++'
  189. version 1.37 or 1.42--are much less reliable than the versions
  190. integrated with GCC 2.  Moreover, combining G++ `1.XX' with a version 2
  191. GCC will simply not work.
  192.  
  193. File: gcc.info,  Node: C Dialect Options,  Next: C++ Dialect Options,  Prev: Invoking G++,  Up: Invoking GCC
  194.  
  195. Options Controlling C Dialect
  196. =============================
  197.  
  198.    The following options control the dialect of C (or languages derived
  199. from C, such as C++ and Objective C) that the compiler accepts:
  200.  
  201. `-ansi'
  202.      Support all ANSI standard C programs.
  203.  
  204.      This turns off certain features of GNU C that are incompatible
  205.      with ANSI C, such as the `asm', `inline' and `typeof' keywords, and
  206.      predefined macros such as `unix' and `vax' that identify the type
  207.      of system you are using.  It also enables the undesirable and
  208.      rarely used ANSI trigraph feature, and disallows `$' as part of
  209.      identifiers.
  210.  
  211.      The alternate keywords `__asm__', `__extension__', `__inline__'
  212.      and `__typeof__' continue to work despite `-ansi'.  You would not
  213.      want to use them in an ANSI C program, of course, but it is useful
  214.      to put them in header files that might be included in compilations
  215.      done with `-ansi'.  Alternate predefined macros such as `__unix__'
  216.      and `__vax__' are also available, with or without `-ansi'.
  217.  
  218.      The `-ansi' option does not cause non-ANSI programs to be rejected
  219.      gratuitously.  For that, `-pedantic' is required in addition to
  220.      `-ansi'.  *Note Warning Options::.
  221.  
  222.      The macro `__STRICT_ANSI__' is predefined when the `-ansi' option
  223.      is used.  Some header files may notice this macro and refrain from
  224.      declaring certain functions or defining certain macros that the
  225.      ANSI standard doesn't call for; this is to avoid interfering with
  226.      any programs that might use these names for other things.
  227.  
  228.      The functions `alloca', `abort', `exit', and `_exit' are not
  229.      builtin functions when `-ansi' is used.
  230.  
  231. `-fno-asm'
  232.      Do not recognize `asm', `inline' or `typeof' as a keyword.  These
  233.      words may then be used as identifiers.  You can use the keywords
  234.      `__asm__', `__inline__' and `__typeof__' instead.  `-ansi' implies
  235.      `-fno-asm'.
  236.  
  237. `-fno-builtin'
  238.      Don't recognize builtin functions that do not begin with two
  239.      leading underscores.  Currently, the functions affected include
  240.      `abort', `abs', `alloca', `cos', `exit', `fabs', `ffs', `labs',
  241.      `memcmp', `memcpy', `sin', `sqrt', `strcmp', `strcpy', and
  242.      `strlen'.
  243.  
  244.      GCC normally generates special code to handle certain builtin
  245.      functions more efficiently; for instance, calls to `alloca' may
  246.      become single instructions that adjust the stack directly, and
  247.      calls to `memcpy' may become inline copy loops.  The resulting
  248.      code is often both smaller and faster, but since the function
  249.      calls no longer appear as such, you cannot set a breakpoint on
  250.      those calls, nor can you change the behavior of the functions by
  251.      linking with a different library.
  252.  
  253.      The `-ansi' option prevents `alloca' and `ffs' from being builtin
  254.      functions, since these functions do not have an ANSI standard
  255.      meaning.
  256.  
  257. `-trigraphs'
  258.      Support ANSI C trigraphs.  You don't want to know about this
  259.      brain-damage.  The `-ansi' option implies `-trigraphs'.
  260.  
  261. `-traditional'
  262.      Attempt to support some aspects of traditional C compilers.
  263.      Specifically:
  264.  
  265.         * All `extern' declarations take effect globally even if they
  266.           are written inside of a function definition.  This includes
  267.           implicit declarations of functions.
  268.  
  269.         * The newer keywords `typeof', `inline', `signed', `const' and
  270.           `volatile' are not recognized.  (You can still use the
  271.           alternative keywords such as `__typeof__', `__inline__', and
  272.           so on.)
  273.  
  274.         * Comparisons between pointers and integers are always allowed.
  275.  
  276.         * Integer types `unsigned short' and `unsigned char' promote to
  277.           `unsigned int'.
  278.  
  279.         * Out-of-range floating point literals are not an error.
  280.  
  281.         * Certain constructs which ANSI regards as a single invalid
  282.           preprocessing number, such as `0xe-0xd', are treated as
  283.           expressions instead.
  284.  
  285.         * String "constants" are not necessarily constant; they are
  286.           stored in writable space, and identical looking constants are
  287.           allocated separately.  (This is the same as the effect of
  288.           `-fwritable-strings'.)
  289.  
  290.         * All automatic variables not declared `register' are preserved
  291.           by `longjmp'.  Ordinarily, GNU C follows ANSI C: automatic
  292.           variables not declared `volatile' may be clobbered.
  293.  
  294.         * The character escape sequences `\x' and `\a' evaluate as the
  295.           literal characters `x' and `a' respectively.  Without
  296.           `-traditional', `\x' is a prefix for the hexadecimal
  297.           representation of a character, and `\a' produces a bell.
  298.  
  299.         * In C++ programs, assignment to `this' is permitted with
  300.           `-traditional'.  (The option `-fthis-is-variable' also has
  301.           this effect.)
  302.  
  303.      You may wish to use `-fno-builtin' as well as `-traditional' if
  304.      your program uses names that are normally GNU C builtin functions
  305.      for other purposes of its own.
  306.  
  307.      You cannot use `-traditional' if you include any header files that
  308.      rely on ANSI C features.  Some vendors are starting to ship
  309.      systems with ANSI C header files and you cannot use `-traditional'
  310.      on such systems to compile files that include any system headers.
  311.  
  312. `'
  313.      In the preprocessor, comments convert to nothing at all, rather
  314.      than to a space.  This allows traditional token concatenation.
  315.  
  316. `'
  317.      In preprocessor directive, the `#' symbol must appear as the first
  318.      character of a line.
  319.  
  320. `'
  321.      In the preprocessor, macro arguments are recognized within string
  322.      constants in a macro definition (and their values are stringified,
  323.      though without additional quote marks, when they appear in such a
  324.      context).  The preprocessor always considers a string constant to
  325.      end at a newline.
  326.  
  327. `'
  328.      The predefined macro `__STDC__' is not defined when you use
  329.      `-traditional', but `__GNUC__' is (since the GNU extensions which
  330.      `__GNUC__' indicates are not affected by `-traditional').  If you
  331.      need to write header files that work differently depending on
  332.      whether `-traditional' is in use, by testing both of these
  333.      predefined macros you can distinguish four situations: GNU C,
  334.      traditional GNU C, other ANSI C compilers, and other old C
  335.      compilers.  *Note Standard Predefined Macros: (cpp.info)Standard
  336.      Predefined, for more discussion of these and other predefined
  337.      macros.
  338.  
  339. `'
  340.      The preprocessor considers a string constant to end at a newline
  341.      (unless the newline is escaped with `\').  (Without `-traditional',
  342.      string constants can contain the newline character as typed.)
  343.  
  344. `-traditional-cpp'
  345.      Attempt to support some aspects of traditional C preprocessors.
  346.      This includes the last five items in the table immediately above,
  347.      but none of the other effects of `-traditional'.
  348.  
  349. `-fcond-mismatch'
  350.      Allow conditional expressions with mismatched types in the second
  351.      and third arguments.  The value of such an expression is void.
  352.  
  353. `-funsigned-char'
  354.      Let the type `char' be unsigned, like `unsigned char'.
  355.  
  356.      Each kind of machine has a default for what `char' should be.  It
  357.      is either like `unsigned char' by default or like `signed char' by
  358.      default.
  359.  
  360.      Ideally, a portable program should always use `signed char' or
  361.      `unsigned char' when it depends on the signedness of an object.
  362.      But many programs have been written to use plain `char' and expect
  363.      it to be signed, or expect it to be unsigned, depending on the
  364.      machines they were written for.  This option, and its inverse, let
  365.      you make such a program work with the opposite default.
  366.  
  367.      The type `char' is always a distinct type from each of `signed
  368.      char' or `unsigned char', even though its behavior is always just
  369.      like one of those two.
  370.  
  371. `-fsigned-char'
  372.      Let the type `char' be signed, like `signed char'.
  373.  
  374.      Note that this is equivalent to `-fno-unsigned-char', which is the
  375.      negative form of `-funsigned-char'.  Likewise, the option
  376.      `-fno-signed-char' is equivalent to `-funsigned-char'.
  377.  
  378. `-fsigned-bitfields'
  379. `-funsigned-bitfields'
  380. `-fno-signed-bitfields'
  381. `-fno-unsigned-bitfields'
  382.      These options control whether a bitfield is signed or unsigned,
  383.      when the declaration does not use either `signed' or `unsigned'.
  384.      By default, such a bitfield is signed, because this is consistent:
  385.      the basic integer types such as `int' are signed types.
  386.  
  387.      However, when `-traditional' is used, bitfields are all unsigned
  388.      no matter what.
  389.  
  390. `-fwritable-strings'
  391.      Store string constants in the writable data segment and don't
  392.      uniquize them.  This is for compatibility with old programs which
  393.      assume they can write into string constants.  The option
  394.      `-traditional' also has this effect.
  395.  
  396.      Writing into string constants is a very bad idea; "constants"
  397.      should be constant.
  398.  
  399. `-fallow-single-precision'
  400.      Do not promote single precision math operations to double
  401.      precision, even when compiling with `-traditional'.
  402.  
  403.      Traditional K&R C promotes all floating point operations to double
  404.      precision, regardless of the sizes of the operands.   On the
  405.      architecture for which you are compiling, single precision may be
  406.      faster than double precision.   If you must use `-traditional',
  407.      but want to use single precision operations when the operands are
  408.      single precision, use this option.   This option has no effect
  409.      when compiling with ANSI or GNU C conventions (the default).
  410.  
  411. File: gcc.info,  Node: C++ Dialect Options,  Next: Warning Options,  Prev: C Dialect Options,  Up: Invoking GCC
  412.  
  413. Options Controlling C++ Dialect
  414. ===============================
  415.  
  416.    This section describes the command-line options that are only
  417. meaningful for C++ programs; but you can also use most of the GNU
  418. compiler options regardless of what language your program is in.  For
  419. example, you might compile a file `firstClass.C' like this:
  420.  
  421.      g++ -g -felide-constructors -O -c firstClass.C
  422.  
  423. In this example, only `-felide-constructors' is an option meant only
  424. for C++ programs; you can use the other options with any language
  425. supported by GNU CC.
  426.  
  427.    Here is a list of options that are *only* for compiling C++ programs:
  428.  
  429. `-fall-virtual'
  430.      Treat all possible member functions as virtual, implicitly.  All
  431.      member functions (except for constructor functions and `new' or
  432.      `delete' member operators) are treated as virtual functions of the
  433.      class where they appear.
  434.  
  435.      This does not mean that all calls to these member functions will
  436.      be made through the internal table of virtual functions.  Under
  437.      some circumstances, the compiler can determine that a call to a
  438.      given virtual function can be made directly; in these cases the
  439.      calls are direct in any case.
  440.  
  441. `-fdollars-in-identifiers'
  442.      Accept `$' in identifiers.  You can also explicitly prohibit use of
  443.      `$' with the option `-fno-dollars-in-identifiers'.  (GNU C++
  444.      allows `$' by default on some target systems but not others.)
  445.      Traditional C allowed the character `$' to form part of
  446.      identifiers.  However, ANSI C and C++ forbid `$' in identifiers.
  447.  
  448. `-felide-constructors'
  449.      Elide constructors when this seems plausible.  With this option,
  450.      GNU C++ initializes `y' directly from the call to `foo' without
  451.      going through a temporary in the following code:
  452.  
  453.           A foo ();
  454.           A y = foo ();
  455.  
  456.      Without this option, GNU C++ (1) initializes `y' by calling the
  457.      appropriate constructor for type `A'; (2) assigns the result of
  458.      `foo' to a temporary; and, finally, (3) replaces the initial value
  459.      of `y' with the temporary.
  460.  
  461.      The default behavior (`-fno-elide-constructors') is specified by
  462.      the draft ANSI C++ standard.  If your program's constructors have
  463.      side effects, `-felide-constructors' can change your program's
  464.      behavior, since some constructor calls may be omitted.
  465.  
  466. `-fenum-int-equiv'
  467.      Permit implicit conversion of `int' to enumeration types.  Normally
  468.      GNU C++ allows conversion of `enum' to `int', but not the other
  469.      way around.
  470.  
  471. `-fexternal-templates'
  472.      Produce smaller code for template declarations, by generating only
  473.      a single copy of each template function where it is defined.  To
  474.      use this option successfully, you must also mark all files that
  475.      use templates with either `#pragma implementation' (the
  476.      definition) or `#pragma interface' (declarations).  *Note
  477.      Declarations and Definitions in One Header: C++ Interface, for more
  478.      discussion of these pragmas.
  479.  
  480.      When your code is compiled with `-fexternal-templates', all
  481.      template instantiations are external.  You must arrange for all
  482.      necessary instantiations to appear in the implementation file; you
  483.      can do this with a `typedef' that references each instantiation
  484.      needed.  Conversely, when you compile using the default option
  485.      `-fno-external-templates', all template instantiations are
  486.      explicitly internal.
  487.  
  488.      You do not need to specify `-fexternal-templates' when compiling a
  489.      file that does not define and instantiate templates used in other
  490.      files, even if your file *uses* templates defined in other files
  491.      that are compiled with `-fexternal-templates'.  The only side
  492.      effect is an increase in object size for each file that you
  493.      compile without `-fexternal-templates'.
  494.  
  495. `-fhandle-signatures'
  496.      Recognize the `signature' and `sigof' keywords for specifying
  497.      abstract types.  The default (`-fno-handle-signatures') is not to
  498.      recognize them.  *Note Type Abstraction using Signatures: C++
  499.      Signatures.
  500.  
  501. `-fmemoize-lookups'
  502. `-fsave-memoized'
  503.      Use heuristics to compile faster.  These heuristics are not
  504.      enabled by default, since they are only effective for certain
  505.      input files.  Other input files compile more slowly.
  506.  
  507.      The first time the compiler must build a call to a member function
  508.      (or reference to a data member), it must (1) determine whether the
  509.      class implements member functions of that name; (2) resolve which
  510.      member function to call (which involves figuring out what sorts of
  511.      type conversions need to be made); and (3) check the visibility of
  512.      the member function to the caller.  All of this adds up to slower
  513.      compilation.  Normally, the second time a call is made to that
  514.      member function (or reference to that data member), it must go
  515.      through the same lengthy process again.  This means that code like
  516.      this:
  517.  
  518.           cout << "This " << p << " has " << n << " legs.\n";
  519.  
  520.      makes six passes through all three steps.  By using a software
  521.      cache, a "hit" significantly reduces this cost.  Unfortunately,
  522.      using the cache introduces another layer of mechanisms which must
  523.      be implemented, and so incurs its own overhead.
  524.      `-fmemoize-lookups' enables the software cache.
  525.  
  526.      Because access privileges (visibility) to members and member
  527.      functions may differ from one function context to the next, G++
  528.      may need to flush the cache.  With the `-fmemoize-lookups' flag,
  529.      the cache is flushed after every function that is compiled.  The
  530.      `-fsave-memoized' flag enables the same software cache, but when
  531.      the compiler determines that the context of the last function
  532.      compiled would yield the same access privileges of the next
  533.      function to compile, it preserves the cache.  This is most helpful
  534.      when defining many member functions for the same class: with the
  535.      exception of member functions which are friends of other classes,
  536.      each member function has exactly the same access privileges as
  537.      every other, and the cache need not be flushed.
  538.  
  539. `-fno-strict-prototype'
  540.      Treat a function declaration with no arguments, such as `int foo
  541.      ();', as C would treat it--as saying nothing about the number of
  542.      arguments or their types.  Normally, such a declaration in C++
  543.      means that the function `foo' takes no arguments.
  544.  
  545. `-fnonnull-objects'
  546.      Assume that objects reached through references are not null.
  547.  
  548.      Normally, GNU C++ makes conservative assumptions about objects
  549.      reached through references.  For example, the compiler must check
  550.      that `a' is not null in code like the following:
  551.  
  552.           obj &a = g ();
  553.           a.f (2);
  554.  
  555.      Checking that references of this sort have non-null values requires
  556.      extra code, however, and it is unnecessary for many programs.  You
  557.      can use `-fnonnull-objects' to omit the checks for null, if your
  558.      program doesn't require checking.
  559.  
  560. `-fthis-is-variable'
  561.      Permit assignment to `this'.  The incorporation of user-defined
  562.      free store management into C++ has made assignment to `this' an
  563.      anachronism.  Therefore, by default it is invalid to assign to
  564.      `this' within a class member function; that is, GNU C++ treats the
  565.      type of `this' in a member function of class `X' to be `X *const'.
  566.      However, for backwards compatibility, you can make it valid with
  567.      `-fthis-is-variable'.
  568.  
  569. `-nostdinc++'
  570.      Do not search for header files in the standard directories
  571.      specific to C++, but do still search the other standard
  572.      directories.  (This option is used when building libg++.)
  573.  
  574. `-traditional'
  575.      For C++ programs (in addition to the effects that apply to both C
  576.      and C++), this has the same effect as `-fthis-is-variable'.  *Note
  577.      Options Controlling C Dialect: C Dialect Options.
  578.  
  579.    In addition, these optimization, warning, and code generation options
  580. have meanings only for C++ programs:
  581.  
  582. `-fno-default-inline'
  583.      Do not assume `inline' for functions defined inside a class scope.
  584.      *Note Options That Control Optimization: Optimize Options.
  585.  
  586. `-Wenum-clash'
  587. `-Woverloaded-virtual'
  588. `-Wtemplate-debugging'
  589.      Warnings that apply only to C++ programs.  *Note Options to
  590.      Request or Suppress Warnings: Warning Options.
  591.  
  592. `+eN'
  593.      Control how virtual function definitions are used, in a fashion
  594.      compatible with `cfront' 1.x.  *Note Options for Code Generation
  595.      Conventions: Code Gen Options.
  596.  
  597. File: gcc.info,  Node: Warning Options,  Next: Debugging Options,  Prev: C++ Dialect Options,  Up: Invoking GCC
  598.  
  599. Options to Request or Suppress Warnings
  600. =======================================
  601.  
  602.    Warnings are diagnostic messages that report constructions which are
  603. not inherently erroneous but which are risky or suggest there may have
  604. been an error.
  605.  
  606.    You can request many specific warnings with options beginning `-W',
  607. for example `-Wimplicit' to request warnings on implicit declarations.
  608. Each of these specific warning options also has a negative form
  609. beginning `-Wno-' to turn off warnings; for example, `-Wno-implicit'.
  610. This manual lists only one of the two forms, whichever is not the
  611. default.
  612.  
  613.    These options control the amount and kinds of warnings produced by
  614. GNU CC:
  615.  
  616. `-fsyntax-only'
  617.      Check the code for syntax errors, but don't do anything beyond
  618.      that.
  619.  
  620. `-w'
  621.      Inhibit all warning messages.
  622.  
  623. `-Wno-import'
  624.      Inhibit warning messages about the use of `#import'.
  625.  
  626. `-pedantic'
  627.      Issue all the warnings demanded by strict ANSI standard C; reject
  628.      all programs that use forbidden extensions.
  629.  
  630.      Valid ANSI standard C programs should compile properly with or
  631.      without this option (though a rare few will require `-ansi').
  632.      However, without this option, certain GNU extensions and
  633.      traditional C features are supported as well.  With this option,
  634.      they are rejected.
  635.  
  636.      `-pedantic' does not cause warning messages for use of the
  637.      alternate keywords whose names begin and end with `__'.  Pedantic
  638.      warnings are also disabled in the expression that follows
  639.      `__extension__'.  However, only system header files should use
  640.      these escape routes; application programs should avoid them.
  641.      *Note Alternate Keywords::.
  642.  
  643.      This option is not intended to be useful; it exists only to satisfy
  644.      pedants who would otherwise claim that GNU CC fails to support the
  645.      ANSI standard.
  646.  
  647.      Some users try to use `-pedantic' to check programs for strict ANSI
  648.      C conformance.  They soon find that it does not do quite what they
  649.      want: it finds some non-ANSI practices, but not all--only those
  650.      for which ANSI C *requires* a diagnostic.
  651.  
  652.      A feature to report any failure to conform to ANSI C might be
  653.      useful in some instances, but would require considerable
  654.      additional work and would be quite different from `-pedantic'.  We
  655.      recommend, rather, that users take advantage of the extensions of
  656.      GNU C and disregard the limitations of other compilers.  Aside
  657.      from certain supercomputers and obsolete small machines, there is
  658.      less and less reason ever to use any other C compiler other than
  659.      for bootstrapping GNU CC.
  660.  
  661. `-pedantic-errors'
  662.      Like `-pedantic', except that errors are produced rather than
  663.      warnings.
  664.  
  665. `-W'
  666.      Print extra warning messages for these events:
  667.  
  668.         * A nonvolatile automatic variable might be changed by a call to
  669.           `longjmp'.  These warnings as well are possible only in
  670.           optimizing compilation.
  671.  
  672.           The compiler sees only the calls to `setjmp'.  It cannot know
  673.           where `longjmp' will be called; in fact, a signal handler
  674.           could call it at any point in the code.  As a result, you may
  675.           get a warning even when there is in fact no problem because
  676.           `longjmp' cannot in fact be called at the place which would
  677.           cause a problem.
  678.  
  679.         * A function can return either with or without a value.
  680.           (Falling off the end of the function body is considered
  681.           returning without a value.)  For example, this function would
  682.           evoke such a warning:
  683.  
  684.                foo (a)
  685.                {
  686.                  if (a > 0)
  687.                    return a;
  688.                }
  689.  
  690.         * An expression-statement contains no side effects.
  691.  
  692.         * An unsigned value is compared against zero with `>' or `<='.
  693.  
  694.         * A comparison like `x<=y<=z' appears; this is equivalent to
  695.           `(x<=y ? 1 : 0) <= z', which is a different interpretation
  696.           from that of ordinary mathematical notation.
  697.  
  698.         * Storage-class specifiers like `static' are not the first
  699.           things in a declaration.  According to the C Standard, this
  700.           usage is obsolescent.
  701.  
  702.         * An aggregate has a partly bracketed initializer.  For
  703.           example, the following code would evoke such a warning,
  704.           because braces are missing around the initializer for `x.h':
  705.  
  706.                struct s { int f, g; };
  707.                struct t { struct s h; int i; };
  708.                struct t x = { 1, 2, 3 };
  709.  
  710. `-Wimplicit'
  711.      Warn whenever a function or parameter is implicitly declared.
  712.  
  713. `-Wreturn-type'
  714.      Warn whenever a function is defined with a return-type that
  715.      defaults to `int'.  Also warn about any `return' statement with no
  716.      return-value in a function whose return-type is not `void'.
  717.  
  718. `-Wunused'
  719.      Warn whenever a local variable is unused aside from its
  720.      declaration, whenever a function is declared static but never
  721.      defined, whenever a label is declared but not used, and whenever a
  722.      statement computes a result that is explicitly not used.
  723.  
  724. `-Wswitch'
  725.      Warn whenever a `switch' statement has an index of enumeral type
  726.      and lacks a `case' for one or more of the named codes of that
  727.      enumeration.  (The presence of a `default' label prevents this
  728.      warning.)  `case' labels outside the enumeration range also
  729.      provoke warnings when this option is used.
  730.  
  731. `-Wcomment'
  732.      Warn whenever a comment-start sequence `/*' appears in a comment.
  733.  
  734. `-Wtrigraphs'
  735.      Warn if any trigraphs are encountered (assuming they are enabled).
  736.  
  737. `-Wformat'
  738.      Check calls to `printf' and `scanf', etc., to make sure that the
  739.      arguments supplied have types appropriate to the format string
  740.      specified.
  741.  
  742. `-Wchar-subscripts'
  743.      Warn if an array subscript has type `char'.  This is a common cause
  744.      of error, as programmers often forget that this type is signed on
  745.      some machines.
  746.  
  747. `-Wuninitialized'
  748.      An automatic variable is used without first being initialized.
  749.  
  750.      These warnings are possible only in optimizing compilation,
  751.      because they require data flow information that is computed only
  752.      when optimizing.  If you don't specify `-O', you simply won't get
  753.      these warnings.
  754.  
  755.      These warnings occur only for variables that are candidates for
  756.      register allocation.  Therefore, they do not occur for a variable
  757.      that is declared `volatile', or whose address is taken, or whose
  758.      size is other than 1, 2, 4 or 8 bytes.  Also, they do not occur for
  759.      structures, unions or arrays, even when they are in registers.
  760.  
  761.      Note that there may be no warning about a variable that is used
  762.      only to compute a value that itself is never used, because such
  763.      computations may be deleted by data flow analysis before the
  764.      warnings are printed.
  765.  
  766.      These warnings are made optional because GNU CC is not smart
  767.      enough to see all the reasons why the code might be correct
  768.      despite appearing to have an error.  Here is one example of how
  769.      this can happen:
  770.  
  771.           {
  772.             int x;
  773.             switch (y)
  774.               {
  775.               case 1: x = 1;
  776.                 break;
  777.               case 2: x = 4;
  778.                 break;
  779.               case 3: x = 5;
  780.               }
  781.             foo (x);
  782.           }
  783.  
  784.      If the value of `y' is always 1, 2 or 3, then `x' is always
  785.      initialized, but GNU CC doesn't know this.  Here is another common
  786.      case:
  787.  
  788.           {
  789.             int save_y;
  790.             if (change_y) save_y = y, y = new_y;
  791.             ...
  792.             if (change_y) y = save_y;
  793.           }
  794.  
  795.      This has no bug because `save_y' is used only if it is set.
  796.  
  797.      Some spurious warnings can be avoided if you declare all the
  798.      functions you use that never return as `volatile'.  *Note Function
  799.      Attributes::.
  800.  
  801. `-Wparentheses'
  802.      Warn if parentheses are omitted in certain contexts, such as when
  803.      there is an assignment in a context where a truth value is
  804.      expected, or when operators are nested whose precedence people
  805.      often get confused about.
  806.  
  807. `-Wenum-clash'
  808.      Warn about conversion between different enumeration types.  (C++
  809.      only).
  810.  
  811. `-Wtemplate-debugging'
  812.      When using templates in a C++ program, warn if debugging is not yet
  813.      fully available (C++ only).
  814.  
  815. `-Wall'
  816.      All of the above `-W' options combined.  These are all the options
  817.      which pertain to usage that we recommend avoiding and that we
  818.      believe is easy to avoid, even in conjunction with macros.
  819.  
  820.    The remaining `-W...' options are not implied by `-Wall' because
  821. they warn about constructions that we consider reasonable to use, on
  822. occasion, in clean programs.
  823.  
  824. `-Wtraditional'
  825.      Warn about certain constructs that behave differently in
  826.      traditional and ANSI C.
  827.  
  828.         * Macro arguments occurring within string constants in the
  829.           macro body.  These would substitute the argument in
  830.           traditional C, but are part of the constant in ANSI C.
  831.  
  832.         * A function declared external in one block and then used after
  833.           the end of the block.
  834.  
  835.         * A `switch' statement has an operand of type `long'.
  836.  
  837. `-Wshadow'
  838.      Warn whenever a local variable shadows another local variable.
  839.  
  840. `-Wid-clash-LEN'
  841.      Warn whenever two distinct identifiers match in the first LEN
  842.      characters.  This may help you prepare a program that will compile
  843.      with certain obsolete, brain-damaged compilers.
  844.  
  845. `-Wlarger-than-LEN'
  846.      Warn whenever an object of larger than LEN bytes is defined.
  847.  
  848. `-Wpointer-arith'
  849.      Warn about anything that depends on the "size of" a function type
  850.      or of `void'.  GNU C assigns these types a size of 1, for
  851.      convenience in calculations with `void *' pointers and pointers to
  852.      functions.
  853.  
  854. `-Wbad-function-cast'
  855.      Warn whenever a function call is cast to a non-matching type.  For
  856.      example, warn if `int malloc()' is cast to `anything *'.
  857.  
  858. `-Wcast-qual'
  859.      Warn whenever a pointer is cast so as to remove a type qualifier
  860.      from the target type.  For example, warn if a `const char *' is
  861.      cast to an ordinary `char *'.
  862.  
  863. `-Wcast-align'
  864.      Warn whenever a pointer is cast such that the required alignment
  865.      of the target is increased.  For example, warn if a `char *' is
  866.      cast to an `int *' on machines where integers can only be accessed
  867.      at two- or four-byte boundaries.
  868.  
  869. `-Wwrite-strings'
  870.      Give string constants the type `const char[LENGTH]' so that
  871.      copying the address of one into a non-`const' `char *' pointer
  872.      will get a warning.  These warnings will help you find at compile
  873.      time code that can try to write into a string constant, but only
  874.      if you have been very careful about using `const' in declarations
  875.      and prototypes.  Otherwise, it will just be a nuisance; this is
  876.      why we did not make `-Wall' request these warnings.
  877.  
  878. `-Wconversion'
  879.      Warn if a prototype causes a type conversion that is different
  880.      from what would happen to the same argument in the absence of a
  881.      prototype.  This includes conversions of fixed point to floating
  882.      and vice versa, and conversions changing the width or signedness
  883.      of a fixed point argument except when the same as the default
  884.      promotion.
  885.  
  886.      Also, warn if a negative integer constant expression is implicitly
  887.      converted to an unsigned type.  For example, warn about the
  888.      assignment `x = -1' if `x' is unsigned.  But do not warn about
  889.      explicit casts like `(unsigned) -1'.
  890.  
  891. `-Waggregate-return'
  892.      Warn if any functions that return structures or unions are defined
  893.      or called.  (In languages where you can return an array, this also
  894.      elicits a warning.)
  895.  
  896. `-Wstrict-prototypes'
  897.      Warn if a function is declared or defined without specifying the
  898.      argument types.  (An old-style function definition is permitted
  899.      without a warning if preceded by a declaration which specifies the
  900.      argument types.)
  901.  
  902. `-Wmissing-prototypes'
  903.      Warn if a global function is defined without a previous prototype
  904.      declaration.  This warning is issued even if the definition itself
  905.      provides a prototype.  The aim is to detect global functions that
  906.      fail to be declared in header files.
  907.  
  908. `-Wmissing-declarations'
  909.      Warn if a global function is defined without a previous
  910.      declaration.  Do so even if the definition itself provides a
  911.      prototype.  Use this option to detect global functions that are
  912.      not declared in header files.
  913.  
  914. `-Wredundant-decls'
  915.      Warn if anything is declared more than once in the same scope,
  916.      even in cases where multiple declaration is valid and changes
  917.      nothing.
  918.  
  919. `-Wnested-externs'
  920.      Warn if an `extern' declaration is encountered within an function.
  921.  
  922. `-Winline'
  923.      Warn if a function can not be inlined, and either it was declared
  924.      as inline, or else the `-finline-functions' option was given.
  925.  
  926. `-Woverloaded-virtual'
  927.      Warn when a derived class function declaration may be an error in
  928.      defining a virtual function (C++ only).  In a derived class, the
  929.      definitions of virtual functions must match the type signature of a
  930.      virtual function declared in the base class.  With this option, the
  931.      compiler warns when you define a function with the same name as a
  932.      virtual function, but with a type signature that does not match any
  933.      declarations from the base class.
  934.  
  935. `-Werror'
  936.      Make all warnings into errors.
  937.  
  938. File: gcc.info,  Node: Debugging Options,  Next: Optimize Options,  Prev: Warning Options,  Up: Invoking GCC
  939.  
  940. Options for Debugging Your Program or GNU CC
  941. ============================================
  942.  
  943.    GNU CC has various special options that are used for debugging
  944. either your program or GCC:
  945.  
  946. `-g'
  947.      Produce debugging information in the operating system's native
  948.      format (stabs, COFF, XCOFF, or DWARF).  GDB can work with this
  949.      debugging information.
  950.  
  951.      On most systems that use stabs format, `-g' enables use of extra
  952.      debugging information that only GDB can use; this extra information
  953.      makes debugging work better in GDB but will probably make other
  954.      debuggers crash or refuse to read the program.  If you want to
  955.      control for certain whether to generate the extra information, use
  956.      `-gstabs+', `-gstabs', `-gxcoff+', `-gxcoff', `-gdwarf+', or
  957.      `-gdwarf' (see below).
  958.  
  959.      Unlike most other C compilers, GNU CC allows you to use `-g' with
  960.      `-O'.  The shortcuts taken by optimized code may occasionally
  961.      produce surprising results: some variables you declared may not
  962.      exist at all; flow of control may briefly move where you did not
  963.      expect it; some statements may not be executed because they
  964.      compute constant results or their values were already at hand;
  965.      some statements may execute in different places because they were
  966.      moved out of loops.
  967.  
  968.      Nevertheless it proves possible to debug optimized output.  This
  969.      makes it reasonable to use the optimizer for programs that might
  970.      have bugs.
  971.  
  972.      The following options are useful when GNU CC is generated with the
  973.      capability for more than one debugging format.
  974.  
  975. `-ggdb'
  976.      Produce debugging information in the native format (if that is
  977.      supported), including GDB extensions if at all possible.
  978.  
  979. `-gstabs'
  980.      Produce debugging information in stabs format (if that is
  981.      supported), without GDB extensions.  This is the format used by
  982.      DBX on most BSD systems.  On MIPS and Alpha systems this option
  983.      produces embedded stabs debugging output which is not understood
  984.      by DBX.
  985.  
  986. `-gstabs+'
  987.      Produce debugging information in stabs format (if that is
  988.      supported), using GNU extensions understood only by the GNU
  989.      debugger (GDB).  The use of these extensions is likely to make
  990.      other debuggers crash or refuse to read the program.
  991.  
  992. `-gcoff'
  993.      Produce debugging information in COFF format (if that is
  994.      supported).  This is the format used by SDB on most System V
  995.      systems prior to System V Release 4.
  996.  
  997. `-gxcoff'
  998.      Produce debugging information in XCOFF format (if that is
  999.      supported).  This is the format used by the DBX debugger on IBM
  1000.      RS/6000 systems.
  1001.  
  1002. `-gxcoff+'
  1003.      Produce debugging information in XCOFF format (if that is
  1004.      supported), using GNU extensions understood only by the GNU
  1005.      debugger (GDB).  The use of these extensions is likely to make
  1006.      other debuggers crash or refuse to read the program.
  1007.  
  1008. `-gdwarf'
  1009.      Produce debugging information in DWARF format (if that is
  1010.      supported).  This is the format used by SDB on most System V
  1011.      Release 4 systems.
  1012.  
  1013. `-gdwarf+'
  1014.      Produce debugging information in DWARF format (if that is
  1015.      supported), using GNU extensions understood only by the GNU
  1016.      debugger (GDB).  The use of these extensions is likely to make
  1017.      other debuggers crash or refuse to read the program.
  1018.  
  1019. `-gLEVEL'
  1020. `-ggdbLEVEL'
  1021. `-gstabsLEVEL'
  1022. `-gcoffLEVEL'
  1023. `-gxcoffLEVEL'
  1024. `-gdwarfLEVEL'
  1025.      Request debugging information and also use LEVEL to specify how
  1026.      much information.  The default level is 2.
  1027.  
  1028.      Level 1 produces minimal information, enough for making backtraces
  1029.      in parts of the program that you don't plan to debug.  This
  1030.      includes descriptions of functions and external variables, but no
  1031.      information about local variables and no line numbers.
  1032.  
  1033.      Level 3 includes extra information, such as all the macro
  1034.      definitions present in the program.  Some debuggers support macro
  1035.      expansion when you use `-g3'.
  1036.  
  1037. `-p'
  1038.      Generate extra code to write profile information suitable for the
  1039.      analysis program `prof'.  You must use this option when compiling
  1040.      the source files you want data about, and you must also use it when
  1041.      linking.
  1042.  
  1043. `-pg'
  1044.      Generate extra code to write profile information suitable for the
  1045.      analysis program `gprof'.  You must use this option when compiling
  1046.      the source files you want data about, and you must also use it when
  1047.      linking.
  1048.  
  1049. `-a'
  1050.      Generate extra code to write profile information for basic blocks,
  1051.      which will record the number of times each basic block is
  1052.      executed, the basic block start address, and the function name
  1053.      containing the basic block.  If `-g' is used, the line number and
  1054.      filename of the start of the basic block will also be recorded.
  1055.      If not overridden by the machine description, the default action is
  1056.      to append to the text file `bb.out'.
  1057.  
  1058.      This data could be analyzed by a program like `tcov'.  Note,
  1059.      however, that the format of the data is not what `tcov' expects.
  1060.      Eventually GNU `gprof' should be extended to process this data.
  1061.  
  1062. `-dLETTERS'
  1063.      Says to make debugging dumps during compilation at times specified
  1064.      by LETTERS.  This is used for debugging the compiler.  The file
  1065.      names for most of the dumps are made by appending a word to the
  1066.      source file name (e.g.  `foo.c.rtl' or `foo.c.jump').  Here are the
  1067.      possible letters for use in LETTERS, and their meanings:
  1068.  
  1069.     `M'
  1070.           Dump all macro definitions, at the end of preprocessing, and
  1071.           write no output.
  1072.  
  1073.     `N'
  1074.           Dump all macro names, at the end of preprocessing.
  1075.  
  1076.     `D'
  1077.           Dump all macro definitions, at the end of preprocessing, in
  1078.           addition to normal output.
  1079.  
  1080.     `y'
  1081.           Dump debugging information during parsing, to standard error.
  1082.  
  1083.     `r'
  1084.           Dump after RTL generation, to `FILE.rtl'.
  1085.  
  1086.     `x'
  1087.           Just generate RTL for a function instead of compiling it.
  1088.           Usually used with `r'.
  1089.  
  1090.     `j'
  1091.           Dump after first jump optimization, to `FILE.jump'.
  1092.  
  1093.     `s'
  1094.           Dump after CSE (including the jump optimization that sometimes
  1095.           follows CSE), to `FILE.cse'.
  1096.  
  1097.     `L'
  1098.           Dump after loop optimization, to `FILE.loop'.
  1099.  
  1100.     `t'
  1101.           Dump after the second CSE pass (including the jump
  1102.           optimization that sometimes follows CSE), to `FILE.cse2'.
  1103.  
  1104.     `f'
  1105.           Dump after flow analysis, to `FILE.flow'.
  1106.  
  1107.     `c'
  1108.           Dump after instruction combination, to the file
  1109.           `FILE.combine'.
  1110.  
  1111.     `S'
  1112.           Dump after the first instruction scheduling pass, to
  1113.           `FILE.sched'.
  1114.  
  1115.     `l'
  1116.           Dump after local register allocation, to `FILE.lreg'.
  1117.  
  1118.     `g'
  1119.           Dump after global register allocation, to `FILE.greg'.
  1120.  
  1121.     `R'
  1122.           Dump after the second instruction scheduling pass, to
  1123.           `FILE.sched2'.
  1124.  
  1125.     `J'
  1126.           Dump after last jump optimization, to `FILE.jump2'.
  1127.  
  1128.     `d'
  1129.           Dump after delayed branch scheduling, to `FILE.dbr'.
  1130.  
  1131.     `k'
  1132.           Dump after conversion from registers to stack, to
  1133.           `FILE.stack'.
  1134.  
  1135.     `a'
  1136.           Produce all the dumps listed above.
  1137.  
  1138.     `m'
  1139.           Print statistics on memory usage, at the end of the run, to
  1140.           standard error.
  1141.  
  1142.     `p'
  1143.           Annotate the assembler output with a comment indicating which
  1144.           pattern and alternative was used.
  1145.  
  1146. `-fpretend-float'
  1147.      When running a cross-compiler, pretend that the target machine
  1148.      uses the same floating point format as the host machine.  This
  1149.      causes incorrect output of the actual floating constants, but the
  1150.      actual instruction sequence will probably be the same as GNU CC
  1151.      would make when running on the target machine.
  1152.  
  1153. `-save-temps'
  1154.      Store the usual "temporary" intermediate files permanently; place
  1155.      them in the current directory and name them based on the source
  1156.      file.  Thus, compiling `foo.c' with `-c -save-temps' would produce
  1157.      files `foo.i' and `foo.s', as well as `foo.o'.
  1158.  
  1159. `-print-file-name=LIBRARY'
  1160.      Print the full absolute name of the library file LIBRARY that
  1161.      would be used when linking--and don't do anything else.  With this
  1162.      option, GNU CC does not compile or link anything; it just prints
  1163.      the file name.
  1164.  
  1165. `-print-prog-name=PROGRAM'
  1166.      Like `-print-file-name', but searches for a program such as `cpp'.
  1167.  
  1168. `-print-libgcc-file-name'
  1169.      Same as `-print-file-name=libgcc.a'.
  1170.  
  1171.      This is useful when you use `-nostdlib' but you do want to link
  1172.      with `libgcc.a'.  You can do
  1173.  
  1174.           gcc -nostdlib FILES... `gcc -print-libgcc-file-name`
  1175.  
  1176.